import packageJson from '../package.json';

const { name, version, config } = packageJson;

const fontThemeConfig = {
  isGlobalControlled: true,
  name: '文本设置',
  code: 'font',
  type: 'FontGroup',
  value: {
    fontSize: 12,
    fontFamily: 'siyuan',
    color: '',
    fontWeight: 'normal',
  },
  themePath: {
    color: 'lightColorList[0]',
  },
};

export default {
  code: name,
  version,
  width: config.width,
  height: config.height,
  coordinate: {
    x: 0,
    y: 0,
  },
  config: [
    {
      name: '搜索框配置',
      code: 'searchConfig',
      children: [
        {
          name: '提示文字',
          code: 'promptText',
          value: '请输入搜索内容',
          type: 'Input',
        },
        {
          name: '文本设置',
          code: 'searchFontCode',
          value: {
            fontSize: 12,
            fontFamily: 'siyuan',
            color: 'rgba(255, 255, 255, 0.85)',
            fontWeight: 'normal',
          },
          type: 'FontGroup',
        },
        {
          name: '背景模糊',
          code: 'bgBlur',
          value: 0,
          min: 0,
          type: 'InputNumber',
          unit: 'px',
        },
        {
          name: '边框粗细',
          code: 'searchBorderSize',
          value: 1,
          min: 0,
          type: 'InputNumber',
          unit: 'px',
        },
        {
          name: '边框颜色',
          code: 'searchBorderColor',
          type: 'ColorSelector',
          value: 'rgba(27,100,238,0.85)',
        },
        {
          name: '背景图片',
          code: 'bgImg',
          type: 'ImgUpdate',
        },
        {
          name: '背景颜色',
          code: 'searchBgColor',
          type: 'ColorSelector',
          value: 'rgba(70,72,234,0.5)',
        },
        {
          name: '组件隐藏后是否清空变量',
          code: 'isInitVar',
          value: false,
          type: 'CheckBox',
        },
      ],
    },
    {
      name: '搜索结果列表',
      code: 'resultConfig',
      children: [
        {
          name: '预览分析框',
          code: 'resultPriview',
          value: false,
          type: 'CheckBox',
        },
        {
          name: '默认配置',
          code: 'defaultConfig',
          children: [
            {
              code: 'position',
              text: '位置',
              type: 'doubleInput',
              value: '0,60',
              min: 0,
            },
            {
              code: 'size',
              text: '尺寸',
              type: 'doubleInput',
              value: '242,480',
              min: 0,
            },
            {
              name: '背景模糊',
              code: 'bgBlur',
              value: 0,
              min: 0,
              type: 'InputNumber',
              unit: 'px',
            },
            {
              name: '背景图片',
              code: 'bgImg',
              type: 'ImgUpdate',
            },
            {
              name: '背景颜色',
              code: 'resultBg',
              type: 'ColorSelector',
              value: 'rgba(70,72,234,0.5)',
            },
            {
              name: '标题文本设置',
              code: 'titleFontCode',
              value: {
                fontSize: 13,
                fontFamily: 'siyuan',
                color: 'rgba(255, 255, 255, 1)',
                fontWeight: 'normal',
              },
              type: 'FontGroup',
            },
            {
              name: '内容文本设置',
              code: 'contentFontCode',
              value: {
                fontSize: 12,
                fontFamily: 'siyuan',
                color: 'rgba(255, 255, 255, 0.85)',
                fontWeight: 'normal',
              },
              type: 'FontGroup',
            },
          ],
        },
        {
          name: '选中配置',
          code: 'activeConfig',
          children: [
            {
              name: '选中背景图片',
              code: 'bgImg',
              type: 'ImgUpdate',
            },
            {
              name: '行选中背景',
              code: 'rowActiveBg',
              type: 'ColorSelector',
              value: 'rgba(70,72,234,0.5)',
            },
            {
              name: '标题文本设置',
              code: 'titleFontCode',
              value: {
                fontSize: 13,
                fontFamily: 'siyuan',
                color: 'rgba(255, 255, 255, 1)',
                fontWeight: 'normal',
              },
              type: 'FontGroup',
            },
            {
              name: '内容文本设置',
              code: 'contentFontCode',
              value: {
                fontSize: 12,
                fontFamily: 'siyuan',
                color: 'rgba(255, 255, 255, 0.85)',
                fontWeight: 'normal',
              },
              type: 'FontGroup',
            },
          ],
        },
      ],
    },
    {
      name: '分页设置',
      code: 'button',
      children: [
        {
          name: '开启分页',
          code: 'open',
          type: 'CheckBox',
          value: true,
        },
        {
          name: '每页显示行数',
          code: 'rowSize',
          type: 'InputNumber',
          value: 10,
          min: 1,
        },
        {
          name: '按钮默认设置',
          code: 'defaults',
          children: [
            {
              name: '按钮大小',
              code: 'size',
              min: 12,
              max: 100,
              value: 24,
              type: 'InputNumber',
              unit: 'px',
            },
            fontThemeConfig,
            {
              name: '边框粗细',
              code: 'borderWidth',
              min: 0,
              value: 1,
              type: 'InputNumber',
              unit: 'px',
            },
            {
              isGlobalControlled: true,
              name: '边框颜色',
              code: 'borderColor',
              value: '',
              type: 'ColorSelector',
              themePath: 'themeColorList[2]',
            },
            {
              isGlobalControlled: true,
              name: '背景颜色',
              code: 'backgroundColor',
              value: '',
              type: 'ColorSelector',
              themePath: 'themeColorList[5]',
            },
          ],
        },
        {
          name: '按钮选中设置',
          code: 'active',
          children: [
            fontThemeConfig,
            {
              name: '边框粗细',
              code: 'borderWidth',
              min: 0,
              value: 1,
              type: 'InputNumber',
              unit: 'px',
            },
            {
              isGlobalControlled: true,
              name: '边框颜色',
              code: 'borderColor',
              value: '',
              type: 'ColorSelector',
              themePath: 'themeColorList[1]',
            },
            {
              isGlobalControlled: true,
              name: '背景颜色',
              code: 'backgroundColor',
              value: '',
              type: 'ColorSelector',
              themePath: 'themeColorList[1]',
            },
          ],
        },
      ],
    },
  ],
  data: {
    field: [
      { name: 'id', mapper: 'id' },
      { name: 'text', mapper: 'senseName' },
      { name: 'desc', mapper: 'senseDesc' },
    ],
    type: 1,
    value: JSON.stringify([
      {
        id: 'ons_light|5001',
        senseName: '十四校西侧站点灯杆',
        senseDesc: '[1]星悦国际校区门口任性道无人打扫长期存在卫生乱差现象,十四街十字路口经常存在违规摆摊!',
        imgUrl: '',
      },
      {
        id: 'ons_light|5002',
        senseName: '魏都新城C区南站点灯杆',
        senseDesc: '[2]星悦国际校区门口任性道无人打扫长期存在卫生乱差现象!',
        imgUrl: '',
      },
      {
        id: 'ons_light|5003',
        senseName: '魏都大道源茂街交叉口东站点智能灯杆',
        senseDesc: '[3]星悦国际校区门口任性道无人打扫长期存在卫生乱差现象!',
        imgUrl: '',
      },
    ]),
  },
  events: {
    click: {
      description: '搜索响应事件',
      fields: {
        keyWord: {
          mapper: '',
          description: '关键词',
        },
        id: {
          mapper: '',
          description: '结果ID',
        },
      },
    },
  },
};
